/**
 * %分片%
 * %v1.0%
 */
package com.leehom.arch.base.shard.repository;

import java.util.Date;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.leehom.arch.base.shard.model.Shard;
import com.leehom.arch.base.shard.model.ShardId;

/**
 * @类名: ShardRepository
 * @说明: 分片库
 * 
 * @author leehom
 * @Date 
 * 
 * @see
 *
 * 修改记录：
 * 
 */
@Repository
public interface ShardRepository extends JpaRepository<Shard, ShardId> {

	@Query("update Shard shard " 
		        + "set shard.current.nvalue = :nvalue "
				+ "where shard.id.owner = :owner and shard.id.resource = :resource")
	@Modifying
	public void updateMarker(@Param("owner") String owner, @Param("resource") String resource,  @Param("nvalue") Long nvalue);
	
	@Query("update Shard shard " 
	        + "set shard.current.dvalue = :dvalue "
			+ "where shard.id.owner = :owner and shard.id.resource = :resource")
	@Modifying
	public void updateMarker(@Param("owner") String owner, @Param("resource") String resource,  @Param("dvalue") Date dvalue);
	
	@Query("update Shard shard " 
	        + "set shard.current.svalue = :svalue "
			+ "where shard.id.owner = :owner and shard.id.resource = :resource")
	@Modifying
	public void updateMarker(String owner, String resource, String svalue);
	
}
